<template>
    <view
        @tap="__e"
        @touchmove.stop.prevent="__e"
        class="mask data-v-b3908c0e"
        :data-event-opts="[
            ['tap', [['cancel', ['$event']]]],
            ['touchmove', [['', ['$event']]]]
        ]"
    >
        <view @tap.stop.prevent="__e" class="mask-content data-v-b3908c0e" :data-event-opts="[['tap', [['', ['$event']]]]]" v-if="isInit && !isReturnSaleSuccess">
            <view @tap.stop.prevent="__e" class="close data-v-b3908c0e" :data-event-opts="[['tap', [['cancel', ['$event']]]]]">
                <image class="data-v-b3908c0e" src="https://img121.7dun.com/yuanqimali/mybox/resalePopupClose.png"></image>
            </view>
            <view class="title data-v-b3908c0e">转售给朋友</view>
            <view class="sku-list data-v-b3908c0e" :scrollY="true" v-if="$root.g0 <= 6">
                <view class="sku-c data-v-b3908c0e" v-for="(item, index) in skus" :key="index">
                    <view class="stock-c data-v-b3908c0e">{{ 'x' + item.total }}</view>

                    <image class="sku-thumb data-v-b3908c0e" mode="aspectFit" :src="item.thumb"></image>

                    <view class="sku-title data-v-b3908c0e">{{ item.title }}</view>

                    <view class="price-c data-v-b3908c0e">
                        单价:
                        <price-display @__l="__l" class="data-v-b3908c0e" :info="item" :vueId="'0984295c-1-' + index"></price-display>
                    </view>
                </view>
            </view>
            <scroll-view class="sku-list scroll-list data-v-b3908c0e" :scrollY="true" v-else>
                <view class="sku-c data-v-b3908c0e" v-for="(item, index) in skus" :key="index">
                    <view class="stock-c data-v-b3908c0e">{{ 'x' + item.total }}</view>

                    <image class="sku-thumb data-v-b3908c0e" mode="aspectFit" :src="item.thumb"></image>

                    <view class="sku-title data-v-b3908c0e">{{ item.title }}</view>

                    <view class="price-c data-v-b3908c0e">
                        <price-display @__l="__l" class="data-v-b3908c0e" :info="item" :vueId="'0984295c-2-' + index"></price-display>
                    </view>
                </view>
            </scroll-view>
            <view class="input-tips data-v-b3908c0e">
                使用建议一口价:
                <switch
                    @change="__e"
                    :checked="isUseAdvisePrice"
                    class="redpack-switch data-v-b3908c0e"
                    color="#9DF9FC"
                    :data-event-opts="[['change', [['switchChange', ['$event']]]]]"
                ></switch>
            </view>
            <view class="money-c data-v-b3908c0e">
                <block v-if="!isUseAdvisePrice">
                    <view class="input-tips data-v-b3908c0e" style="margin: 0">
                        是否公开:
                        <switch
                            @change="__e"
                            :checked="gongkPrice"
                            class="redpack-switch data-v-b3908c0e"
                            color="#9DF9FC"
                            :data-event-opts="[['change', [['gongkChange', ['$event']]]]]"
                        ></switch>
                    </view>
                    <input
                        @blur="__e"
                        @input="__e"
                        class="input money-input data-v-b3908c0e"
                        :data-event-opts="[
                            ['input', [['__set_model', ['', 'moneyPrice', '$event', ['number']]]]],
                            ['blur', [['$forceUpdate']]]
                        ]"
                        placeholder="现金价"
                        :value="moneyPrice"
                    />
                    <label class="_span data-v-b3908c0e">元</label>
                </block>
                <block v-else>
                    <label class="_span data-v-b3908c0e">{{ moneyPrice }}</label>
                    <label class="_span data-v-b3908c0e">元</label>
                </block>
            </view>
            <view class="btn-cs data-v-b3908c0e">
                <view @tap="__e" class="btn data-v-b3908c0e" :data-event-opts="[['tap', [['cancel', ['$event']]]]]">再想想</view>
                <view @tap="__e" class="btn submit data-v-b3908c0e" :data-event-opts="[['tap', [['submit', ['$event']]]]]">确认转售</view>
            </view>
        </view>
    </view>
</template>

<script>
import priceDisplay from '@/components/PriceDisplay/PriceDisplay';
import tabBar from '@/components/TabBar/tabBar';
(global.webpackJsonp = global.webpackJsonp || []).push([
    ['components/ResalePopup/ResalePopup'],
    {
        '0455': function (e, i, t) {},
        '8d49': function (e, i, t) {
            'use strict';

            t.r(i);
            var n = t('f9d9');
            var s = t.n(n);
            for (var c in n) {
                if (['default'].indexOf(c) < 0) {
                    (function (e) {
                        t.d(i, e, function () {
                            return n[e];
                        });
                    })(c);
                }
            }
            i.default = s.a;
        },
        ca32: function (e, i, t) {
            'use strict';

            var n = t('0455');
            t.n(n).a;
        },
        cd4e: function (e, i, t) {
            'use strict';

            t.r(i);
            var n = t('d36c');
            var s = t('8d49');
            for (var c in s) {
                if (['default'].indexOf(c) < 0) {
                    (function (e) {
                        t.d(i, e, function () {
                            return s[e];
                        });
                    })(c);
                }
            }
            t('ca32');
            var o = t('f0c5');
            var a = Object(o.a)(s.default, n.b, n.c, false, null, 'b3908c0e', null, false, n.a, void 0);
            i.default = a.exports;
        },
        d36c: function (e, i, t) {
            'use strict';

            t.d(i, 'b', function () {
                return s;
            });
            t.d(i, 'c', function () {
                return c;
            });
            t.d(i, 'a', function () {
                return n;
            });
            var n = {
                PriceDisplay: function () {
                    return t.e('components/PriceDisplay/PriceDisplay').then(t.bind(null, '6b05'));
                }
            };
            var s = function () {
                this.$createElement;
                var e = (this._self._c, this.isInit && !this.isReturnSaleSuccess ? this.skus.length : null);
                this.setData(
                    Object.assign(
                        {},
                        {
                            $root: {
                                g0: e
                            }
                        }
                    )
                );
            };
            var c = [];
        },
        f9d9: function (e, i, t) {
            'use strict';

            (function (e) {
                Object.defineProperty(i, '__esModule', {
                    value: true
                });
                i.default = void 0;
                var t = {
                    components: {},
                    data: function () {
                        return {
                            info: {},
                            skus: [],
                            isInit: false,
                            isReturnSaleSuccess: false,
                            moneyPrice: '',
                            scorePrice: '',
                            gongkPrice: 0,
                            isUseAdvisePrice: 1,
                            adviseMoneyPrice: '',
                            adviseScorePrice: ''
                        };
                    },
                    props: {
                        uuid: {
                            type: String
                        },
                        packageSku: {
                            type: Object
                        }
                    },
                    computed: {},
                    watch: {
                        isUseAdvisePrice: function (e) {
                            if (e) {
                                this.moneyPrice = this.adviseMoneyPrice / 100;
                                this.scorePrice = 0;
                            }
                        }
                    },
                    onLoad: function (e) {},
                    created: function () {
                        this.initOrder();
                    },
                    methods: {
                        gongkChange: function (e) {
                            this.gongkPrice = e.detail.value ? 1 : 0;
                        },
                        switchChange: function (e) {
                            this.isUseAdvisePrice = e.detail.value ? 1 : 0;
                        },
                        initOrder: function () {
                            var that = this;
                            e.showLoading();
                            this.$http('/asset/resale/preview', 'post', {
                                ids: [this.packageSku.id]
                            }).then(function (t) {
                                that.isInit = true;
                                that.skus = t.data.skus;
                                that.info = t.data;
                                that.moneyPrice = that.info.advise_money_price / 100;
                                that.scorePrice = 0;
                                that.adviseMoneyPrice = that.info.advise_money_price;
                                that.adviseScorePrice = that.info.advise_score_price;
                                e.hideLoading();
                            });
                        },
                        cancel: function () {
                            this.$emit('cancel');
                        },
                        submit: function () {
                            var that = this;
                            return '' === this.moneyPrice
                                ? (e.showModal({
                                      title: '请填现金价，免费请填0哦~'
                                  }),
                                  false)
                                : '' === this.scorePrice
                                ? (e.showModal({
                                      title: '请填积分价，免费请填0哦~'
                                  }),
                                  false)
                                : (e.showLoading(),
                                  void this.$http('/asset/resales', 'post', {
                                      package_sku_id: this.packageSku.id,
                                      is_public: this.gongkPrice,
                                      is_allow_fast_match: this.isUseAdvisePrice,
                                      money_price: this.moneyPrice ? 100 * this.moneyPrice : 0,
                                      score_price: 0
                                  }).then(function (t) {
                                      e.hideLoading();
                                      that.$emit('cancel');
                                      that.$emit('refresh');
                                      e.navigateTo({
                                          url: '/pages/resale/detail?uuid=' + t.data.uuid
                                      });
                                  }));
                        },
                        toPage: function (i) {
                            e.navigateTo({
                                url: i
                            });
                        }
                    },
                    onPageScroll: function (e) {}
                };
                i.default = t;
            }.call(this, t('543d').default));
        }
    }
]);
(global.webpackJsonp = global.webpackJsonp || []).push([
    'components/ResalePopup/ResalePopup-create-component',
    {
        'components/ResalePopup/ResalePopup-create-component': function (e, i, t) {
            t('543d').createComponent(t('cd4e'));
        }
    },
    [['components/ResalePopup/ResalePopup-create-component']]
]);
</script>
<style>
@import './ResalePopup.css';
</style>
